﻿using System;
using System.Web.Mvc;

namespace MyMvc.Common
{
    [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
    public class LogHandleErrorFilters : HandleErrorAttribute
    {

        public override void OnException(ExceptionContext filterContext)
        {
            //记录报错信息
            if (!filterContext.ExceptionHandled)
            {
                string controllerName = (string)filterContext.RouteData.Values["controller"];
                string actionName = (string)filterContext.RouteData.Values["action"];
                string msgTemplate = "在执行 controller[{0}] 的 action[{1}] 时产生异常";
                //LogManager.GetLogger("LogExceptionAttribute").Error(string.Format(msgTemplate, controllerName, actionName), filterContext.Exception);
            }

            base.OnException(filterContext);
        }
    }
}